package project.web;

import com.alibaba.fastjson.JSON;
import project.pojo.Course;
import project.service.TeacherService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URLEncoder;

@WebServlet("/deleteCourseSingleServlet")
public class DeleteCourseSingleServlet extends HttpServlet {
    private TeacherService service = new TeacherService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String courseId = request.getParameter("courseId");
        System.out.println(courseId);
        boolean flag = service.deleteCourseSingle(Long.parseLong(courseId));
        System.out.println(flag);
        if(flag){
            response.getWriter().write("success");
        }else{
            response.getWriter().write("unsuccess");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
